package com.sinosoft.online.schedule;

import org.bouncycastle.crypto.RuntimeCryptoException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sinosoft.online.request.JavaHttpRequest;
import com.sinosoft.online.webservice.constant.WebServiceConstants;
import com.sinosoft.online.webservice.dto.Header;
import com.sinosoft.online.webservice.dto.Online;
import com.sinosoft.online.webservice.dto.Request;
import com.sinosoft.online.webservice.util.WSUtil;

/**
 * WebService 服务调度任务
 * @author leichao
 *
 */
public class SyncOnlineSchedule {
	
	private String application;
	
	private String url;
	
	private Logger logger = LoggerFactory.getLogger(SyncOnlineSchedule.class);
	
	public void setUrl(String url) {
		this.url = url;
	}

	public void setApplication(String application) {
		this.application = application;
	}

	/**
	 * 推送机构信息方法
	 * @param groupEntity 机构信息实体
	 * @param str 执行操作类型
	 */
	public void excute() {
		if(this.application==null||this.url==null){
			throw new RuntimeException("时间调度函数excute()调用失败，application或url为空");
		}
		String num = JavaHttpRequest.sendGet(this.url, "");
		Online online = new Online(this.application,num);
		Header header = new Header("PDT_11", WebServiceConstants.RECEIVE_PLAT_ID);
		try {
			System.out.println(new Request(header, online).getXmlStr());
			WSUtil.getPushOrganizationClient().acceptMessage(new Request(header, online).getXmlStr());
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("dsdssdsd++++++++++++++++++++++++++++++++");
	}
	
}
